package edu.ccut.titan.tag.report.chart;

import java.awt.Point;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

import edu.ccut.titan.tag.report.servlet.PageSize;

import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRVariable;

public class Type implements IType {
	private Map<String, String> datasetType;
	private Map<String, Byte> chartType;
	private Map<String, String> plotType;
	private Map<String, Byte> functionType;
	private Map<String, Point> pageSizeType;

	public Type() {
		// init data set type
		datasetType = new HashMap<String, String>();
		datasetType.put(IType.CHART_TYPE_LINE, IType.DATASET_TYPE_CATEGORY);
		datasetType.put(IType.CHART_TYPE_PIE, IType.DATASET_TYPE_PIE);
		datasetType.put(IType.CHART_TYPE_PIE3D, IType.DATASET_TYPE_PIE);
		datasetType.put(IType.CHART_TYPE_AREA, IType.DATASET_TYPE_CATEGORY);
		datasetType.put(IType.CHART_TYPE_XYLINE, IType.DATASET_TYPE_XY);
		datasetType.put(IType.CHART_TYPE_XYBAR_TIMESERIES,
				IType.DATASET_TYPE_TIMESERIES);
		datasetType.put(IType.CHART_TYPE_XYBAR_TIMEPERIOT,
				IType.DATASET_TYPE_TIMEPERIOD);
		datasetType.put(IType.CHART_TYPE_XYBAR, IType.DATASET_TYPE_XY);
		datasetType.put(IType.CHART_TYPE_XYAREA, IType.DATASET_TYPE_XY);
		datasetType.put(IType.CHART_TYPE_TIMESERIES,
				IType.DATASET_TYPE_TIMESERIES);
		datasetType.put(IType.CHART_TYPE_THERMOMETER, IType.DATASET_TYPE_VALUE);
		datasetType.put(IType.CHART_TYPE_STACKEDBAR,
				IType.DATASET_TYPE_CATEGORY);
		datasetType.put(IType.CHART_TYPE_STACKEDBAR3D,
				IType.DATASET_TYPE_CATEGORY);
		datasetType.put(IType.CHART_TYPE_STACKEDAREA,
				IType.DATASET_TYPE_CATEGORY);
		datasetType.put(IType.CHART_TYPE_SCATTER, IType.DATASET_TYPE_XY);
		datasetType.put(IType.CHART_TYPE_METER, IType.DATASET_TYPE_VALUE);
		datasetType.put(IType.CHART_TYPE_HIGHLOW, IType.DATASET_TYPE_HIGHLOW);
		datasetType.put(IType.CHART_TYPE_CANDLIESTICK,
				IType.DATASET_TYPE_HIGHLOW);
		datasetType.put(IType.CHART_TYPE_BUBBLE, IType.DATASET_TYPE_XYZ);
		datasetType.put(IType.CHART_TYPE_BAR, IType.DATASET_TYPE_CATEGORY);
		datasetType.put(IType.CHART_TYPE_BAR3D, IType.DATASET_TYPE_CATEGORY);

		// init chart type
		chartType = new HashMap<String, Byte>();
		chartType.put(IType.CHART_TYPE_AREA, JRChart.CHART_TYPE_AREA);
		chartType.put(IType.CHART_TYPE_BAR, JRChart.CHART_TYPE_BAR);
		chartType.put(IType.CHART_TYPE_BAR3D, JRChart.CHART_TYPE_BAR3D);
		chartType.put(IType.CHART_TYPE_BUBBLE, JRChart.CHART_TYPE_BUBBLE);
		chartType.put(IType.CHART_TYPE_CANDLIESTICK,
				JRChart.CHART_TYPE_CANDLESTICK);
		chartType.put(IType.CHART_TYPE_HIGHLOW, JRChart.CHART_TYPE_HIGHLOW);
		chartType.put(IType.CHART_TYPE_LINE, JRChart.CHART_TYPE_LINE);
		chartType.put(IType.CHART_TYPE_METER, JRChart.CHART_TYPE_METER);
		chartType
				.put(IType.CHART_TYPE_MULTIAXIS, JRChart.CHART_TYPE_MULTI_AXIS);
		chartType.put(IType.CHART_TYPE_PIE, JRChart.CHART_TYPE_PIE);
		chartType.put(IType.CHART_TYPE_PIE3D, JRChart.CHART_TYPE_PIE3D);
		chartType.put(IType.CHART_TYPE_SCATTER, JRChart.CHART_TYPE_SCATTER);
		chartType.put(IType.CHART_TYPE_STACKEDAREA,
				JRChart.CHART_TYPE_STACKEDAREA);
		chartType.put(IType.CHART_TYPE_STACKEDBAR,
				JRChart.CHART_TYPE_STACKEDBAR);
		chartType.put(IType.CHART_TYPE_STACKEDBAR3D,
				JRChart.CHART_TYPE_STACKEDBAR3D);
		chartType.put(IType.CHART_TYPE_THERMOMETER,
				JRChart.CHART_TYPE_THERMOMETER);
		chartType.put(IType.CHART_TYPE_TIMESERIES,
				JRChart.CHART_TYPE_TIMESERIES);
		chartType.put(IType.CHART_TYPE_XYAREA, JRChart.CHART_TYPE_XYAREA);
		chartType.put(IType.CHART_TYPE_XYBAR, JRChart.CHART_TYPE_XYBAR);
		chartType.put(IType.CHART_TYPE_XYLINE, JRChart.CHART_TYPE_XYLINE);

		// init plot type
		plotType = new HashMap<String, String>();
		plotType.put(IType.CHART_TYPE_LINE, IType.PLOT_TYPE_LINE);
		plotType.put(IType.CHART_TYPE_AREA, IType.PLOT_TYPE_AREA);
		plotType.put(IType.CHART_TYPE_BAR, IType.PLOT_TYPE_BAR);
		plotType.put(IType.CHART_TYPE_BAR3D, IType.PLOT_TYPE_BAR3D);
		plotType.put(IType.CHART_TYPE_BUBBLE, IType.PLOT_TYPE_BUBBLE);
		plotType
				.put(IType.CHART_TYPE_CANDLIESTICK, IType.PLOT_TYPE_CANDLESTICK);
		plotType.put(IType.CHART_TYPE_HIGHLOW, IType.PLOT_TYPE_HIGHLOW);
		plotType.put(IType.CHART_TYPE_METER, IType.PLOT_TYPE_METER);
		plotType.put(IType.CHART_TYPE_MULTIAXIS, IType.PLOT_TYPE_MULTIAXIS);
		plotType.put(IType.CHART_TYPE_PIE, IType.PLOT_TYPE_PIE);
		plotType.put(IType.CHART_TYPE_PIE3D, IType.PLOT_TYPE_PIE3D);
		plotType.put(IType.CHART_TYPE_SCATTER, IType.PLOT_TYPE_SCATTER);
		plotType.put(IType.CHART_TYPE_STACKEDAREA, IType.PLOT_TYPE_AREA);
		plotType.put(IType.CHART_TYPE_STACKEDBAR, IType.PLOT_TYPE_BAR);
		plotType.put(IType.CHART_TYPE_STACKEDBAR3D, IType.PLOT_TYPE_BAR3D);
		plotType.put(IType.CHART_TYPE_THERMOMETER, IType.PLOT_TYPE_THERMOMETER);
		plotType.put(IType.CHART_TYPE_TIMESERIES, IType.CHART_TYPE_TIMESERIES);
		plotType.put(IType.CHART_TYPE_XYBAR_TIMEPERIOT, IType.PLOT_TYPE_BAR);
		plotType.put(IType.CHART_TYPE_XYBAR_TIMESERIES, IType.PLOT_TYPE_BAR);
		plotType.put(IType.CHART_TYPE_XYLINE, IType.PLOT_TYPE_LINE);
		plotType.put(IType.CHART_TYPE_XYAREA, IType.PLOT_TYPE_AREA);
		plotType.put(IType.CHART_TYPE_XYBAR, IType.PLOT_TYPE_BAR);

		// function type
		functionType = new HashMap<String, Byte>();
		functionType.put("sum", JRVariable.CALCULATION_SUM);

		// page size type
		pageSizeType = new HashMap<String, Point>();
		pageSizeType.put("A1", PageSize.A1);
		pageSizeType.put("A2", PageSize.A2);
		pageSizeType.put("A3", PageSize.A3);
		pageSizeType.put("A4", PageSize.A4);
		pageSizeType.put("A5", PageSize.A5);
		pageSizeType.put("A6", PageSize.A6);
		pageSizeType.put("A7", PageSize.A7);
		pageSizeType.put("A8", PageSize.A8);
		pageSizeType.put("A9", PageSize.A9);

	}

	public String getDatasetType(String name) {
		return datasetType.get(name);
	}

	public String getPlotType(String name) {
		return plotType.get(name);
	}

	public Byte getFunctionType(String name) {
		return functionType.get(name);
	}

	public Point getPageSize(String name) {
		return pageSizeType.get(name);
	}

	public byte getChartType(String name) {
		return chartType.get(name);
	}

}
